

package com.hexinfo.dmpro.dev.data.transfer.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.dev.data.transfer.model.DesensitizeFunctionConf;
import com.hexinfo.dmpro.dev.data.transfer.service.IDesensitizeFunctionConfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;


/**
 * 脱敏函数配置表
 *
 * @author yyh.huang
 * @date 2023-09-19 18:37:08
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/desensitizefunctionconf" )
@Api(value = "desensitizefunctionconf", tags = "脱敏函数配置表管理")
public class DesensitizeFunctionConfController {

    private final IDesensitizeFunctionConfService desensitizeFunctionConfService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param desensitizeFunctionConf 脱敏函数配置表
     * WrapperEnhancer.like(desensitizeFunctionConf); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getDesensitizeFunctionConfPage(Page page, DesensitizeFunctionConf desensitizeFunctionConf) {
        return new ResponseEntity<>(desensitizeFunctionConfService.queryList(page,desensitizeFunctionConf), HttpStatus.OK);
    }

    /**
     * @Method getDesensitizeFunctionConfNoPage
     * @Param
     * @param desensitizeFunctionConf
     * @Return org.springframework.http.ResponseEntity<java.lang.Object>
     * @Description 不分页查询
     * @Author Wang zhihao
     * @Date 2024/1/2 17:59
     * @Version V1.0
     */
    @ApiOperation(value = "不分页查询", notes = "不分页查询")
    @GetMapping("/noPage" )
    public ResponseEntity<Object> getDesensitizeFunctionConfNoPage(DesensitizeFunctionConf desensitizeFunctionConf) {
        return new ResponseEntity<>(desensitizeFunctionConfService.queryListNoPage(desensitizeFunctionConf), HttpStatus.OK);
    }

    /**
     * 新增脱敏函数配置表
     * @param desensitizeFunctionConf 脱敏函数配置表
     * @return R
     */
    @ApiOperation(value = "新增脱敏函数配置表", notes = "新增脱敏函数配置表")
    @PostMapping
    @AnonymousAccess
    public ResponseEntity<Object> save(@RequestBody DesensitizeFunctionConf desensitizeFunctionConf) {
        return new ResponseEntity<>(desensitizeFunctionConfService.save(desensitizeFunctionConf), HttpStatus.OK);
    }

    /**
     * 修改脱敏函数配置表
     * @param desensitizeFunctionConf 脱敏函数配置表
     * @return R
     */
    @ApiOperation(value = "修改脱敏函数配置表", notes = "修改脱敏函数配置表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody DesensitizeFunctionConf desensitizeFunctionConf) {
        return ResponseEntity.ok(desensitizeFunctionConfService.save(desensitizeFunctionConf));
    }

    /**
     * 通过id删除脱敏函数配置表
     * @param ids id
     * @return R
     */
    @ApiOperation(value = "通过id删除脱敏函数配置表", notes = "通过id删除脱敏函数配置表")
    @DeleteMapping("/{ids}" )
    @AnonymousAccess
    public ResponseEntity<Object> removeByIds(@PathVariable("ids") @NotNull List<String> ids) {
        return ResponseEntity.ok(desensitizeFunctionConfService.removeByIds(ids));
    }

}
